package com.woniu.cq.medical.dao.mymapper;

import com.woniu.cq.medical.dao.MedicineMapper;
import com.woniu.cq.medical.entity.Medicine;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.context.annotation.Primary;

import java.util.List;

/**
 * @Author: Klaus
 * @Date: 2020/9/7 20:39
 */
@Primary
public interface My_MedicineMapper extends MedicineMapper {
    /**
     * 根据药名模糊查询药品
     * @param MedicineName
     * @return 药品的集合
     */
    @Select("SELECT medicine_id,product_pzwh,\n" +
            "product_format,product_name,\n" +
            "product_manufacturer,product_barcode,\n" +
            "product_form,product_wholesale_price,\n" +
            "product_retail_price,create_time \n" +
            "from lonbon_medicine \n" +
            "where product_name LIKE concat('%',#{MedicineName},'%')")
    List<Medicine> selectMedicineLikeName(String MedicineName);

    /**
     * 根据药品名字和规格找出对应的药品
     * @param MedicineName
     * @param ProductFormat
     * @return
     */
    @Select("SELECT medicine_id,product_pzwh,\n" +
            "product_format,product_name,\n" +
            "product_manufacturer,product_barcode,\n" +
            "product_form,product_wholesale_price,\n" +
            "product_retail_price,create_time \n" +
            "from lonbon_medicine \n" +
            "where product_name = #{MedicineName} AND\n" +
            "product_format = #{ProductFormat} ")
    Medicine selectMedicineLikeNameAndProductFormat(@Param("MedicineName") String MedicineName,@Param("ProductFormat") String ProductFormat);

}
